﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace XqWebSite
{
    public partial class WebForm41 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)//判断是否回发
            {
                if (Request["ID"] != null)//判断是否有参数传入
                {
                    InitData();//执行初始化函数
                }
            }
        }
        protected void InitData()
        {
            string id = Request["ID"].ToString();
            try
            {
                string SQL = "select * from AnBao where ID='" + id + "'";
                DataTable dt = DBHelper.GetDataSet(SQL).Tables[0];//获取对应的参数并且对页面进行绑定
                if (dt.Rows.Count > 0)
                {
                }
            }
            catch
            {
            }
        }

        protected void But_tj_Click(object sender, EventArgs e)
        {
            string SQL = "";
            bool iRet = false;
            string id = Tex_id.Text;


            SQL = "update BaoAn set username ='" + Tex_name.Text + "',password ='" + Tex_mm.Text + "',age='" +
                    Tex_nl.Text + "',tel='" + Tex_dh.Text + "',beizhu='" + Tex_bz.Text + "' where ID='" + id + "'";
            iRet = DBHelper.ExecSql(SQL);


            if (iRet)
            {
                DBHelper.ShowMessage(Page, "恭喜您，操作成功！", "");

            }
            else
            {
                DBHelper.ShowMessage(Page, "对不起，操作失败！", "");
            }
            
        }

        protected void But_qx_Click(object sender, EventArgs e)
        {
            Tex_name.Text = "";
            Tex_mm.Text = "";
            Tex_nl.Text = "";
            Tex_dh.Text = "";
            Tex_bz.Text = "";
            Response.Redirect("MAnbaoXg.aspx");
        }
    }
}